package com.zd01.controller;

import com.zd01.model.ReportSexModel;
import com.zd01.model.Result;
import com.zd01.servers.ReportServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Slf4j
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportServer reportServer;
    //报表管理，格式一，柱状图
//    {
//        "code": 1,
//            "msg": "success",
//            "data": {
//        "sex": ["男","女"],
//        "sexCount": [3, 12]
//    }
    @GetMapping("/getSex")
    public Result getSex(){
        ReportSexModel reportSexModel = reportServer.getSexCount();
        return Result.success(reportSexModel);

    }
    //报表管理，格式二，饼状图
//    {
//        "code": 1,
//            "msg": "success",
//            "data": [
//        {sex": "女性员工", "num": 3},
//        {"sex": "男性员工","num": 12}
//  ]
//    }
    @GetMapping("/getSex2")
    public Result getSex2(){
        List<Map<String, Object>> reportSex= reportServer.getSexCount2();
        return Result.success(reportSex);

    }
}
